package fresher.model;

import fresher.utility.DatabaseUtility;
import java.sql.ResultSet;
import java.sql.SQLException;

/**
 * Example model test database utility
 *
 * @author kotakakaji
 */
public class ExampleModel {

    /**
     * Get current database name
     *
     * @return database name or empty string if exception occur
     */
    public String getDatabaseName() {
        DatabaseUtility database = new DatabaseUtility();
        String sql = "SELECT database() AS name";
        try {
            ResultSet result = database.query(sql);
            if (result.first()) {
                return result.getString("name");
            } else {
                return "";
            }
        } catch (SQLException sqlException) {
            return "";
        }

    }
}
